package com.qdxwx.data.service.course;

import com.qdxwx.data.mapper.course.CourseTeacherMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * CourseTeacher接口
 * Qdx NetSchool Platform
 * @author qdxwx
 * @updateTime 2022/5/25
 * @description
 */
@Service
public class CourseTeacherServiceImpl implements CourseTeacherService {

	@Autowired
	private CourseTeacherMapper courseTeacherMapper;

	@Override
	public void insert(int courseId, int teacherId) {
		courseTeacherMapper.insertCourseTeacher(courseId, teacherId);
	}

	@Override
	public void insert(int courseId, List<Integer> teacherIds) {
		if (teacherIds.size() < 1) return;
		for (int teacherId : teacherIds) {
			insert(courseId, teacherId);
		}
	}

	@Override
	public List<Integer> getTeacherIds(int courseId) {
		return courseTeacherMapper.selectTeacherIdList(courseId);
	}

	@Override
	public void deleteByCourseId(int courseId) {
		courseTeacherMapper.deleteByCourseId(courseId);
	}

	@Override
	public int countByTeacherId(int id) {
		return courseTeacherMapper.selectCountByTeacherId(id);
	}
}